package com.ns002.yigou.quote.dao;

import com.ns002.yigou.quote.entity.RealTimeQuote;
import com.ns002.yigou.quote.entity.Tuser;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * @Author xu
 * @Date 2017/7/26 0026 下午 8:47
 * 行情数据
 */
@Repository
public interface RealTimeQuoteDao extends PagingAndSortingRepository<RealTimeQuote, Integer>, JpaSpecificationExecutor<Tuser> {

    /**
     * 查询某个行情最后的行情点时间
     * @return
     */
    @Query(value = "SELECT * FROM mk_realtime_quote r WHERE contract = :contract ORDER BY 'timestamp' DESC LIMIT 1 "
            , nativeQuery = true)
    RealTimeQuote findLast(@Param("contract") String contract);

}
